package com.bite.aop.proxy;

//import java.lang.reflect.InvocationHandler;
//import java.lang.reflect.Method;

import org.springframework.cglib.proxy.InvocationHandler;

import java.lang.reflect.Method;


public class JDKInvocation implements InvocationHandler {
    //目标对象/被代理对象
    private Object target;

    public JDKInvocation(HouseSubject target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        //before
        System.out.println("开始代理");
        //通过反射执行目标对象的目标方法
        Object result = method.invoke(target, args);
        //after
        System.out.println("结束代理");
        return result;
    }
}
